<template>
	<view style="padding: 20rpx;">
		<u--form labelPosition="left" :model="userInfo" label-width="70">
			<u-form-item label="旧密码" prop="pwdModel.oldPassword" borderBottom ref="item1">
				<u--input v-model="pwdModel.oldPassword"></u--input>
			</u-form-item>
			<u-form-item label="新密码" prop="pwdModel.password" borderBottom ref="item1">
				<u--input v-model="pwdModel.password"></u--input>
			</u-form-item>
			<u-form-item label="确认密码" prop="pwdModel.repassword" borderBottom ref="item1">
				<u--input v-model="pwdModel.repassword"></u--input>
			</u-form-item>
			<u-form-item>
				<u-button type="primary" @click="updatePwd">提交</u-button>
			</u-form-item>
		</u--form>
	</view>
</template>

<script>
import { updatePwd, updatePwdService } from '../../api/user';
	export default {
		data() {
			return {
				pwdModel: {
					oldPassword: '',
					password: '',
					repassword: ''
				}
			};
		},
		methods: {
			async updatePwd() {
				if(this.pwdModel.password !== this.pwdModel.repassword) {
					return uni.showToast({
						icon:'error',
						title:'密码输入不一致'
					})
				}
				await updatePwdService(this.pwdModel.oldPassword, this.pwdModel.password)
				uni.showToast({
					icon:'success',
					title:'修改成功'
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
